<cfsilent>
	<cfinvoke component="components.NamedGateway" method="getNamedList" returnvariable="queryNamed" />
	<cfquery name="querySelectedUser" datasource="tidtool">
		SELECT *
		FROM
			Person
		WHERE
			Username = '#getAuthUser()#'
	</cfquery>
	<cfparam name="trBackgroundStyle" type="string" default="defaultTRBackground" />
	<cfparam name="tooltipText" type="string" default="" />
</cfsilent>
<cfoutput>
	<div style="padding:5px;">
		<div class="page-title">
			#querySelectedUser.Username#'s aktueller Step: #querySelectedUser.CurrentStep#
		</div>
		<cfif structKeyExists(form, "message") and len(form.message) gt 0>
			<div class="info-message">
				Information: #form.message#
			</div>
		</cfif>
		<form name="" action="components/NamedGateway.cfc" method="post">
			<input type="hidden" name="method" value="updateNamedListByUserID" />
			<input type="hidden" name="userID" value="#querySelectedUser.ID#" />
			<table>
				<tr>
					<th>Name</th>
					<th>Art</th>
					<th>Step</th>
					<th>Brauche ich</th>
					<th>Habe ich Doppelt</th>
				</tr>
				<cfloop query="queryNamed">
					<cfquery name="queryNamedPersonRelation" datasource="tidtool">
						SELECT *
						FROM Named_Person
						WHERE
							NamedID = #queryNamed.ID#
						AND
							PersonID = #querySelectedUser.ID#
					</cfquery>
					<cfquery name="queryNamedDoublePersonRelation" datasource="tidtool">
						SELECT *
						FROM NamedDouble_Person
						WHERE
							NamedID = #queryNamed.ID#
						AND
							PersonID = #querySelectedUser.ID#
					</cfquery>
					<cfif queryNamed.Step gt 0>
						<cfif (queryNamed.Step eq querySelectedUser.CurrentStep) and (queryNamedPersonRelation.recordCount gt 0)>
							<cfset trBackgroundStyle = "redTRBackground" />
							<cfset tooltipText = "#querySelectedUser.Username# braucht diesen Named im aktuellen Step!" />
						<cfelseif queryNamed.Step lt querySelectedUser.CurrentStep>
							<cfset trBackgroundStyle = "greenTRBackground" />
							<cfset tooltipText = "#querySelectedUser.Username# hat diesen Named bereits abgegeben..." />
						<cfelseif queryNamed.Step gt querySelectedUser.CurrentStep>
							<cfset trBackgroundStyle = "yellowTRBackground" />
							<cfset tooltipText = "#querySelectedUser.Username# wird diesen Named in einem sp&auml;teren Step brauchen!" />
						</cfif>
					<cfelse>
						<cfset trBackgroundStyle = "defaultTRBackground" />
						<cfset tooltipText = "Berechnung nicht m&ouml;glich. F&uuml;r diesen Named wurde noch kein Step angegeben..." />
					</cfif>
					<tr class="#trBackgroundStyle#">
						<td>
							<cftooltip hidedelay="400" tooltip="#tooltipText#">
								#queryNamed.MonsterName#
							</cftooltip>
						</td>
						<td>#queryNamed.Type#</td>
						<td>#queryNamed.Step#&nbsp;</td>
						<td>
							<cfif queryNamedPersonRelation.recordCount gt 0>
								<a href="DataManipulatorGateway.cfc?method=deleteMissing&missingID=#queryNamedPersonRelation.ID#&userID=#querySelectedUser.ID#">
									<img src="img/delete.png" title="Brauche ich nicht mehr" alt="l&ouml;schen" />
								</a>
							<cfelseif queryNamed.Step neq 0 and queryNamed.Step lt querySelectedUser.CurrentStep>
								<img src="img/tick.png" title="bereits abgegeben" alt="bereits abgegeben" />
							<cfelse>
								<input type="checkbox" name="namedSequence" value="#queryNamed.ID#" />
							</cfif>
						</td>
						<td>
							<cfif queryNamedDoublePersonRelation.recordCount gt 0>
								<a href="DataManipulatorGateway.cfc?method=deleteDouble&doubleID=#queryNamedDoublePersonRelation.ID#&userID=#querySelectedUser.ID#">
									<img src="img/delete.png" title="Habe ich nicht mehr doppelt" alt="l&ouml;schen" />
								</a>
							<cfelse>
								<input type="checkbox" name="namedDoubleSequence" value="#queryNamed.ID#" />
							</cfif>
						</td>
					</tr>
				</cfloop>
				<tr>
					<td>
						<input type="submit" name="submit" value="speichern" />
					</td>
				</tr>
			</table>
		</form>
	</div>
</cfoutput>